package CCF_2014;

import java.util.Arrays;
import java.util.Scanner;

public class T201409_1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = Integer.valueOf(scanner.nextLine());
        int nums[] = StringToInt(scanner.nextLine().split(" "));
        scanner.close();
        Arrays.sort(nums);
        int n=0;
        for (int i = 1;i<count;i++) {
            if (nums[i]-nums[i-1]==1) {
                n++;
            }
        }
        System.out.println(n);
    }

    private static int[] StringToInt(String ss[]) {
        int array[] = new int[ss.length];
        for (int i = 0;i<ss.length;i++) {
            array[i] = Integer.valueOf(ss[i]);
        }
        return array;
    }
}
